<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../5.25/vue.js"></script>
</head>
<body>
    <div id="app">
        <my-component></my-component>
    </div>
</body>
<script>
    //自定义组件并获取组件上的内容
    Vue.component("my-component",{
        template:"<button @click='root'>查看根元素</div>",
            methods:{
                root(){
                    console.log(this.$root)
                    console.log(this.$root===vm.$root)
                }
            }
    })
    var vm=new Vue({
        el:"#app",
    })
</script>
</html>